//package com.imay.live.manager;
//
//import android.content.Context;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.widget.ImageView;
//import android.widget.RelativeLayout;
//
//import com.bumptech.glide.Glide;
//import com.imay.live.model.BannerInfoModel;
//import com.imay.live.utils.GlideUtil;
//import com.imay.live.view.banner.BannerAdapter;
//import com.imay.live.view.banner.SliderBanner;
//import com.imay.live.R;
//
//import java.util.ArrayList;
//
///**
// * Created by Administrator on 2017/2/14.
// */
//
//public class SliderBannerManager {
//    private Context context;
//    private SliderBanner mSliderBanner;
//    private OnAdClickListener onClickListener;
//    private InnerAdapter mBannerAdapter = new InnerAdapter();
//    private int length = 2;
//
//    public interface OnAdClickListener {
//        void onClick(BannerInfoModel bannerInfoModel);
//    }
//
//    public SliderBannerManager(SliderBanner sliderBanner) {
//        context = sliderBanner.getContext();
//        mSliderBanner = sliderBanner;
//        sliderBanner.setAdapter(mBannerAdapter);
//    }
//
//    /**
//     * 显示banner图
//     *
//     * @param list     //默认图片
//     * @param images   //实际图片
//     * @param listener //监听
//     */
////    public void play(Integer[] list, String[] images, OnAdClickListener listener) {
////
////    }
//
//    /**
//     * 显示banner图
//     *
//     * @param list     //默认图片
//     * @param images   //实际图片
//     * @param listener //监听
//     */
//    public void play(ArrayList<BannerInfoModel> bannerInfoModels, OnAdClickListener listener, int to) {
//        onClickListener = listener;
//        mBannerAdapter.setData(bannerInfoModels);
//        mBannerAdapter.notifyDataSetChanged();
//        if (bannerInfoModels != null && bannerInfoModels.size() != 0) {
//            length = bannerInfoModels.size();
//        }
//        mSliderBanner.setDotNum(length);
//        mSliderBanner.beginPlay(to);
//    }
//
//    public void stopPlay() {
//        if (mSliderBanner != null) {
//            mSliderBanner.stop();
//        }
//    }
//
//    public int getPlayPostion() {
//        if (mSliderBanner != null) {
//            return mSliderBanner.getPlayPostion();
//        }
//        return 0;
//    }
//
////    public void beginPlay() {
////        if (mSliderBanner != null) {
////            mSliderBanner.beginPlay();
////        }
////    }
//
//    public void Playto(int index) {
//        if (mSliderBanner != null) {
//            mSliderBanner.Playto(index);
//        }
//    }
//
//    private class InnerAdapter extends BannerAdapter {
//        //        private Integer[] mDataList;
//        private ArrayList<BannerInfoModel> bannerInfoModelse;
//
//
//        public void setData(ArrayList<BannerInfoModel> bannerInfoModel) {
////            mDataList = data;
//            this.bannerInfoModelse = bannerInfoModel;
//
//        }
//
//        public Object getItem(int position) {
//            if (bannerInfoModelse == null)
//                return null;
////            else
////            if (mDataListImage == null && mDataList != null)
////                return mDataList[getPositionForIndicator(position)];
//            else
//                return bannerInfoModelse.get(getPositionForIndicator(position));
//        }
//
//        @Override
//        public int getPositionForIndicator(int position) {
//            if (null != bannerInfoModelse && bannerInfoModelse.size() != 0) {
//                return position % bannerInfoModelse.size();
//            }
////            if (null != mDataList && mDataList.length != 0) {
////                return position % mDataList.length;
////            }
//            return position % length;
//        }
//
//        @Override
//        public View getView(LayoutInflater layoutInflater, int position) {
//            // UI
//            final int mPosition = position;
//            View viewPagerItem = View.inflate(context, R.layout.view_banner_item, null);
//            ImageView pagerItemImage = (ImageView) viewPagerItem.findViewById(R.id.viewPagerImage);
//            pagerItemImage.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
//
////            Bitmap bitmap = null;
//            final BannerInfoModel bannerInfoModel = (BannerInfoModel) getItem(position);
//            GlideUtil.loadImage(mSliderBanner.getContext(),bannerInfoModel.getAdFile(),pagerItemImage,R.mipmap.placeholder);
////            Glide.with(mSliderBanner.getContext()).load(bannerInfoModel.getAdFile()).error(R.mipmap.placeholder).into(pagerItemImage);
////            if (mDataListImage != null && mDataListImage.length != 0 && new File(mDataListImage[(position % length)]).exists()) {
////                while (bitmap == null) {
////                    bitmap = BitmapFactory.decodeFile(mDataListImage[(position % length)]);
////                }
////                pagerItemImage.setImageBitmap(bitmap);
////            } else {
////                pagerItemImage.setImageResource(mDataList[(position % length)]);
////            }
//            viewPagerItem.setTag(bannerInfoModel.getAdFile());
//            viewPagerItem.setOnClickListener(new View.OnClickListener() {
//
//                @Override
//                public void onClick(View v) {
//                    if (onClickListener != null) {
//                        onClickListener.onClick(bannerInfoModel);
//                    }
//                }
//            });
//            return viewPagerItem;
//        }
//
//        @Override
//        public int getCount() {
//            if (bannerInfoModelse == null) {
//                return 0;
//            }
//            return bannerInfoModelse.size();
//        }
//    }
//
//
//}
